package com.stylefeng.guns.modular.clm.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.ClmColumnRoom;
import com.stylefeng.guns.modular.clm.service.IClmColumnRoomService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-04-25 14:26:18
 */
@Controller
@RequestMapping("/clmColumnRoom")
public class ClmColumnRoomController extends BaseController {

    private String PREFIX = "/clm/clmColumnRoom/";

    @Autowired
    private IClmColumnRoomService clmColumnRoomService;

    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "clmColumnRoom.html";
    }

    /**
     * 跳转到添加
     */
    @RequestMapping("/clmColumnRoom_add")
    public String clmColumnRoomAdd() {
        return PREFIX + "clmColumnRoom_add.html";
    }

    /**
     * 跳转到修改
     */
    @RequestMapping("/clmColumnRoom_update/{clmColumnRoomId}")
    public String clmColumnRoomUpdate(@PathVariable Integer clmColumnRoomId, Model model) {
        ClmColumnRoom clmColumnRoom = clmColumnRoomService.selectById(clmColumnRoomId);
        model.addAttribute("item",clmColumnRoom);
        LogObjectHolder.me().set(clmColumnRoom);
        return PREFIX + "clmColumnRoom_edit.html";
    }

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return clmColumnRoomService.selectList(null);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(ClmColumnRoom clmColumnRoom) {
        clmColumnRoomService.insert(clmColumnRoom);
        return SUCCESS_TIP;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer clmColumnRoomId) {
        clmColumnRoomService.deleteById(clmColumnRoomId);
        return SUCCESS_TIP;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(ClmColumnRoom clmColumnRoom) {
        clmColumnRoomService.updateById(clmColumnRoom);
        return SUCCESS_TIP;
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{clmColumnRoomId}")
    @ResponseBody
    public Object detail(@PathVariable("clmColumnRoomId") Integer clmColumnRoomId) {
        return clmColumnRoomService.selectById(clmColumnRoomId);
    }
}
